//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Serialization;

namespace OpenLS.Drawing
{
    public class ShapeStyle : IOfficeXmlSerializable
    {
        private StyleMatrixReference effectRef;
        private StyleMatrixReference fillRef;
        private FontReference fontRef;
        private StyleMatrixReference lnRef;

        public StyleMatrixReference LineReference //\\
        {
            get { return lnRef; }
            set { lnRef = value; }
        }

        public StyleMatrixReference FillReference
        {
            get { return fillRef; }
            set { fillRef = value; }
        }

        public StyleMatrixReference EffectReference
        {
            get { return effectRef; }
            set { effectRef = value; }
        }

        public FontReference FontReference
        {
            get { return fontRef; }
            set { fontRef = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.ReadAndSwitch("style", DrawingConstants.DrawingNamespaceUri, false))
            {
                c.PassAttributes();
                LineReference = c.ReadElementAs<StyleMatrixReference>("lnRef");
                FillReference = c.ReadElementAs<StyleMatrixReference>("fillRef");
                EffectReference = c.ReadElementAs<StyleMatrixReference>("effectRef");
                FontReference = c.ReadElement<FontReference>();
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.WriteAndSwitch("style", DrawingConstants.DrawingNamespace))
            {
                c.WriteElementAs(LineReference, "lnRef");
                c.WriteElementAs(FillReference, "fillRef");
                c.WriteElementAs(EffectReference, "effectRef");
                c.WriteElement(FontReference);
            }
        }

        #endregion
    }
}